package org.androidpn.server.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.androidpn.server.dao.RoleDao;
import org.androidpn.server.entity.Role;
import org.androidpn.server.service.RoleService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * service 角色
 * 
 * @author 蔡琪
 * 
 */
@Service("roleService")
public class RoleServiceImpl extends BaseServiceImpl<Role, Long> implements
		RoleService {

	@Resource(name = "roleDao")
	private RoleDao roleDao;

	@Resource(name = "roleDao")
	private void setBaseDao(RoleDao roleDao) {
		super.setBaseDao(roleDao);
	}

	@Transactional(readOnly = true)
	public List<Role> getRolesByUserId(Long userId) {
		return roleDao.getRolesByUserId(userId);
	}

	@Transactional(readOnly = true)
	public Role getRoleByNickname(String nickname) {
		return roleDao.getRoleByNickname(nickname);
	}

	@Transactional(readOnly = true)
	public boolean nicknameExist(String nickname) {
		return roleDao.nicknameExist(nickname);
	}

	@Transactional(readOnly = true)
	public List<Role> getRolesByUsername(String username) {
		return roleDao.getRolesByUsername(username);
	}

	@Transactional(readOnly = true)
	public Role getRoleByNicknamAndUsername(String nickname, String username) {
		return roleDao.getRoleByNicknamAndUsername(nickname, username);
	}
}
